//
//  FeedbackViewController.m
//  Stock
//
//  Created by sun black on 12-2-8.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "FeedbackViewController.h"
#import "StockAppHelper.h"

@implementation FeedbackViewController
@synthesize textView;
@synthesize textField;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithTitle:@"发送" style:UIBarButtonItemStyleDone target:self action:@selector(send)];
    self.navigationItem.rightBarButtonItem = done;
    [done release];
    
    self.textView.layer.cornerRadius = 6;
    
}
-(void)send{
    NSString *content = self.textView.text;
    if (content.length < 5) {
        [[StockAppHelper shareInstance] showAlertViewWithMessage:@"请输入最少5个字符"];
        return;
    }
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    [dict setValue:@"1" forKey:@"UMengFeedbackGender"];
    [dict setValue:@"3" forKey:@"UMengFeedbackAge"];
    [dict setValue:[NSString stringWithFormat:@"%@---%@",content,self.textField.text?:@""] forKey:@"UMengFeedbackContent"];
    [MobClick feedbackWithDictionary:dict];
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    self.textField = nil;
    self.textView = nil;
}
-(void)dealloc{
    self.textField = nil;
    self.textView = nil; 
    [super dealloc];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end
